import formBuilder from "@/comps/form/formBuilder";
import api from "./api";
import apiInquiry from "@/pages/v1/erp/Inquiry/js/apiInquiry";
import apiNeed from "@/pages/v1/erp/Need/js/apiNeed";
import apiProduct from "@/pages/v1/erp/Product/js/apiProduct";
import apiUnit from "@/pages/v1/erp/Unit/js/apiUnit";
import apiTaxRate from "@/pages/v1/erp/TaxRate/js/apiTaxRate";
/*
fb.addText("inquiry","询价单",3)
fb.addText("product","产品",3)
fb.addText("num","数量",3)
fb.addText("unit","单位",3)
fb.addText("tax","税率",3)
fb.addText("price","参考单价",3)
fb.addText("money","参考总价",3)
fb.addText("note","备注",3)
fb.addText("row","RN",3)

* */
export default {
    main:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100)

        fb.addSearch("belongToId","询价单",6)
            .setApi(apiInquiry.urlChoice)
            .setApiSearchKeys(["sn__regex","title__regex"])
            .setRules([fb.R.notNull("请输入询价单号")])

        fb.addSearch("productId","产品",6)
            .setApi(apiProduct.urlChoice)
            .setApiSearchKeys(["name__regex","fastName__regex"])
            .setRules([fb.R.notNull("请选择产品")])
        fb.addText("num","数量",2).setTextTypeNumber()
            .setRules([fb.R.notNull("请输入数量")])
        fb.addSelect("unitId","单位",2)
            .setApi(apiUnit.urlChoice)
            .setRules([fb.R.notNull("请选择单位")])
        fb.addSelect("taxRateId","税率",2)
            .setApi(apiTaxRate.urlChoice)
        fb.addText("price","参考价格",2).setTextTypeNumber()
        fb.addText("money","参考总价",2).setTextTypeNumber()
        fb.addText("row","RN",2).setTextTypeNumber()
        fb.addText("note","备注",12)
            .setTextMulti(true)
            .setTextRows(3)

        //
        // fb.addSelect("product","产品",3)
        // fb.addText("num","数量",3)
        // fb.addText("unit","单位",3)
        // fb.addText("price","参考单价",3)
        // fb.addText("note","备注",3)
        // fb.addText("row","RN",3)

        return fb
    },
    tree:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100)

        fb.addCascade("parentId").setLabel("上级分类").setSpan(3)
            .setApi(api.urlTree)

        fb.addText("name").setSpan(6).setLabel("分类名称")
            .setRules([fb.R.notNull("名称不能为空")])

        fb.addText("sort").setSpan(3).setLabel("排序").setTypeNumber()
        return fb
    },
    other:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100).setLabelPosition("right")

        return fb
    }
}